package com.jsbb.config;

import io.minio.MinioClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MinIO配置
 *
 * @author w
 * @date 2021-03-05
 */
@Slf4j
@Configuration
public class MinioConfig {

    @Autowired
    private ParamsConfig paramsConfig;

    @Bean
    public MinioClient minioClient() {
        MinioClient minioClient = null;
        try {
            minioClient = MinioClient.builder()
                    .endpoint(paramsConfig.getMinioEndpoint())
                    .credentials(paramsConfig.getMinioAccessKey(), paramsConfig.getMinioSecretKey())
                    .build();
        } catch (final Exception e) {
            log.error("MinIoClient初始化失败==={}", e.getMessage());
        }
        return minioClient;
    }
}
